<template>
  <view class="door-lock">
    <none-data v-if="roomList.length == 0" />
    <cohabitationItem
    v-for="item in roomList" :key="item.accountNumber"
    :room="item.accountNumber"
    :item="item"
    ></cohabitationItem>
    <view class="tail" v-if="roomList.length !== 0">
      {{ tailText }}
    </view>
  </view>
</template>

<script setup>
import { getUserLockInfoApi } from "@/package_property/pages/api/home";
import cohabitationItem from "@/package_property/pages/components/cohabitation-item/x.vue";
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
import { ref } from "vue";
const current = ref(1);
const pageSize = ref(15);
const tailText = ref("");
const roomList = ref([]);
const total = ref(0);
async function getUserLockInfo() {
  let pageData = {
    page: current.value,
    size: pageSize.value,
  };
  const res = await getUserLockInfoApi(pageData);
  if (res.data.records) {
    roomList.value = res.data.records;
    total.value = res.data.total;
    if (total.value !== roomList.value.length) {
      tailText.value = "下滑加载更多";
    } else {
      tailText.value = "没有更多内容";
    }
  }
}
onLoad(() => {
    getUserLockInfo();
});
onReachBottom(() => {
  if (total.value !== roomList.value.length) {
    current.value++;
    getUserLockInfo();
  }
});
</script>

<style lang="less" scoped>


</style>